using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using Microformats.Entities;
using Microformats.Readers;

namespace MicroformatReader.Tasks
{
    class ProcessMemoryStream
    {
        public void Process()
        {
            Console.Out.WriteLine("Processing Data From MemoryStream");
            Console.Out.WriteLine("=================================");

            using (MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(@"<div class=""vcard author"">
 <a class=""url fn"" href=""http://www.kinlan.co.uk/"">Paul Kinlan</a>
 <a class=""email"" href=""mailto:paul.kinlan@gmail.com"">paul.kinlan@gmail.com</a>
 <div class=""adr"">
  <span class=""locality"">Liverpool</span>,<span class=""region"">Merseyside</span>
 </div>
</div>
</div><a href=""test.com"" rel=""tag"">Test Tag</a>")))
            {
                using (Microformats.Readers.MicroformatReader mr = new Microformats.Readers.MicroformatReader(ms, InputSourceType.Html))
                {
                    Microformat m = null;
                    while(( m= mr.Read()) != null)
                    {
                        Console.Out.Write("Found Microformat: " + m.Name + "\n");
                        
                    }
                    
                }
            }

        }
    }
}
